package com.xls.commonlibrary.http;


import com.xls.commonlibrary.bean.AdCodeResult;
import com.xls.commonlibrary.bean.AdResult;
import com.xls.commonlibrary.bean.AddLogResult;
import com.xls.commonlibrary.bean.BusinessResult;
import com.xls.commonlibrary.bean.LoginResult;
import com.xls.commonlibrary.bean.ShowEcpmResult;
import com.xls.commonlibrary.bean.UpdateEcpmResult;
import com.xls.commonlibrary.bean.UpdateVersionResult;
import com.xls.commonlibrary.bean.UserGameInfo;
import com.xls.commonlibrary.bean.UserResult;
import com.xls.commonlibrary.bean.WxUserResult;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.reactivex.rxjava3.core.Observable;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;

public interface Api {

//    @GET("/getlist")
//    Observable<Result> getList();

    @Deprecated
    @FormUrlEncoded
    // @POST("/appLoginLogs/add")
    // @POST("/appLoginLogs/test")
    // Observable<Result<AddLogResult>> appLoginLogAdd( // data is object
    @POST("/appLoginLogs/test3")
    Observable<Result<List<AddLogResult>>> appLoginLogAdd(// data is list
                                                          @Field("weixin") String weixin,
                                                          @Field("phone") String phone,
                                                          @Field("ip") String ip,
                                                          @Field("apps") String apps,

                                                          @Field("isSim") int isSim,
                                                          @Field("isAirPlane") int isAirPlane,
                                                          @Field("isRoot") int isRoot,
                                                          @Field("isAccessibility") int isAccessibility,
                                                          @Field("isProjection") int isProjection,
                                                          @Field("photos") int photos
    );// 不要这么调用，参数多了，有点麻烦写的，建议用 @FieldMap 简洁


    @FormUrlEncoded
//    @POST("/appLoginLogs/test3")
    // @POST("/appLoginLogs/add")
    @POST("/user/appLogin")
    Observable<Result<List<AddLogResult>>> appLoginLogAdd(@FieldMap Map<String, String> map);


    // 登陆       微信登陆后调用服务器登陆接口
    @FormUrlEncoded
    @POST("/login")
    Observable<Result<LoginResult>> appLogin(@FieldMap Map<String, String> map);

    // 获取播放广告顺序


    // 上传ecpm
    @FormUrlEncoded
    @POST("/secure/updateEcpm")
    Observable<Result<UpdateEcpmResult>> updateEcpm(@FieldMap Map<String, String> map);


    // 播放广告，记录广告ecpm
    // {"code":1,"msg":"success","data":{"editList":[],"playList":["csj","bd","tx","ks"]}}
    @FormUrlEncoded
    @POST("/secure/businessTrans")
    Observable<Result<BusinessResult>> business(@FieldMap Map<String, String> map);

    // 展示给用户当前的收益
    @FormUrlEncoded
    @POST("/secure/showEcpm")
    Observable<Result<ShowEcpmResult>> showEcpm(@FieldMap Map<String, String> map);

    @FormUrlEncoded
    @POST("/updateVersion")
    Observable<Result<UpdateVersionResult>> updateVersion(@FieldMap Map<String, String> map);


    // 获取微信个人信息，头像，昵称之类的
    // 注意是全路径
    //@GET("https://api.weixin.qq.com/sns/userinfo?")
    @GET("sns/userinfo?")
    Observable<WxUserResult> getWxUserInfo(@Query("access_token") String token, @Query("openid") String openID, @Query("lang") String zhCn);

    // 风控with encode
    // @POST("api/user/fkCheck")
    // 全路径  @Url String url
    @FormUrlEncoded
    @POST()
    Observable<Result> fkCheck(@Url String url, @FieldMap Map<String, String> map);

    // 阿里风控token上传服务器
    // /ali/device/callback
    @FormUrlEncoded
    @POST()
    Observable<Result> fkAlibabaCheck(@Url String url, @FieldMap Map<String, String> map);

    // 广告位列表
    @FormUrlEncoded
    @POST("adcode/getAdcode")
    Observable<Result<ArrayList<AdCodeResult>>> getAdcode(@FieldMap Map<String, String> map);


    // 广告位列表ALl
    @FormUrlEncoded
    @POST("adcode/getAdcodeList")
    Observable<Result<AdResult>> getAdcodeList(@FieldMap Map<String, String> map);

    //获取用户游戏账户信息(头像、昵称、积分、级别)
    @FormUrlEncoded
    @POST("game/getUserGameAccount")
    Observable<Result<UserGameInfo>> getUserGameAccount(@FieldMap Map<String, String> map);

    //更新用户游戏级别
    @FormUrlEncoded
    @POST("game/updateUserGameAccount")
    Observable<Result<UserGameInfo>> updateUserGameAccount(@FieldMap Map<String, String> map);


    //调用顺序改为： 1登录服务器成功login  2绑定渠道 gotoGame()  [3需要更新渠道包，升级updateVersion]  4进入游戏jump2Game()
    // [3]  第三步   后台检查渠道，更新信息，返回是否可以更新以及渠道包的apk信息like update接口
    @FormUrlEncoded
    @POST("/yxqdDownload")
    Observable<Result<UpdateVersionResult>> yxqdDownload(@FieldMap Map<String, String> map);

    // 广告回掉埋点
    @Headers({"Content-Type: application/json", "Content-SHA-256: true"})
    @POST("/secure/saveAppUserVideo")
    Observable<Result<LoginResult>> saveAppUserVideo(@Body Map<String, String> map);


    @FormUrlEncoded
    @POST("/game/userHeartbeat")
    Observable<Result> userHeartbeat(@FieldMap Map<String, String> map);

}
